Repository navigation
Analytics: say whether tokens per day count every model call or only runs - #316
Merged
Merged
Conversation
…runs The analytics API now puts the per-call meter's daily totals on the page (every model call: runs, including work on runs started earlier, reviews, follow-ups, chat) instead of what the run records add up to. The chart's title says which one it shows, and the API types carry the metered cost, the run records' cost and what the metered cost was for.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The analytics page's tokens-per-day chart says what it counts. With the platform change that comes with it (CoderHelm/coderhelm-platform, "Cut model spend"), the analytics API reports the per-call usage meter's daily totals: every model call, including PR reviews and work on runs started on earlier days, instead of the sum of the run records (one day read as $78 from run records against $168 metered).
Changes
src/app/analytics/page.tsx: the chart is titled "Tokens per day, every model call" when the API'scost_basisismetered, and "Tokens per day, runs only" otherwise (one repository picked, or an older server).src/lib/api.ts:AnalyticsSummarycarriesrun_cost_usd,cost_basisandcost_by_feature; each day carriesrun_cost_usdandrun_tokensnext to the meteredcost_usdandtokens. The cost per run and per merged PR are documented as coming from the run records.e2e/analytics.spec.ts: the fixture is metered and the test checks the chart's title.The page still measures in tokens, not dollars (#91).
Verification
npm run lint,npm run typecheck,npm run check:openapi,npm run build: pass.e2e/analytics.spec.tsagainst the static build: 14 passed.